#include "stdafx.h"
#include <stdio.h>
#include "gtest/gtest.h"
#include "MathTest.h"

using namespace rs;


class Point3Test : public MathTest
{
};


TEST_F(Point3Test, ctor)
{
	// Point3(f32, f32, f32)
	const Point3 p0(x0, y0, z0);
	EXPECT_FLOAT_EQ(x0, p0.getX());
	EXPECT_FLOAT_EQ(y0, p0.getY());
	EXPECT_FLOAT_EQ(z0, p0.getZ());

	// Point3(const Point3&)
	const Point3 p1 = p0;
	EXPECT_FLOAT_EQ(p0.getX(), p1.getX());
	EXPECT_FLOAT_EQ(p0.getY(), p1.getY());
	EXPECT_FLOAT_EQ(p0.getZ(), p1.getZ());

	// operator =
	Point3 p2;
	p2 = p0;
	EXPECT_FLOAT_EQ(p0.getX(), p2.getX());
	EXPECT_FLOAT_EQ(p0.getY(), p2.getY());
	EXPECT_FLOAT_EQ(p0.getZ(), p2.getZ());
}


TEST_F(Point3Test, add)
{
	const Point3 p0(x0, y0, z0);
	const Vector3 v1(x1, y1, z1);
	Point3 p;

	// operator +=
	p = p0;
	p += v1;
	EXPECT_FLOAT_EQ(x0+x1, p.getX());
	EXPECT_FLOAT_EQ(y0+y1, p.getY());
	EXPECT_FLOAT_EQ(z0+z1, p.getZ());

	// operator +
	p = p0 + v1;
	EXPECT_FLOAT_EQ(x0+x1, p.getX());
	EXPECT_FLOAT_EQ(y0+y1, p.getY());
	EXPECT_FLOAT_EQ(z0+z1, p.getZ());
	p = v1 + p0;
	EXPECT_FLOAT_EQ(x0+x1, p.getX());
	EXPECT_FLOAT_EQ(y0+y1, p.getY());
	EXPECT_FLOAT_EQ(z0+z1, p.getZ());
}


TEST_F(Point3Test, sub)
{
	const Point3 p0(x0, y0, z0);
	const Point3 p1(x1, y1, z1);
	const Vector3 v1(x1, y1, z1);
	Point3 p;
	Vector3 v;

	// operator -=
	p = p0;
	p -= v1;
	EXPECT_FLOAT_EQ(x0-x1, p.getX());
	EXPECT_FLOAT_EQ(y0-y1, p.getY());
	EXPECT_FLOAT_EQ(z0-z1, p.getZ());

	// operator -
	v = p0 - p1;
	EXPECT_FLOAT_EQ(x0-x1, v.getX());
	EXPECT_FLOAT_EQ(y0-y1, v.getY());
	EXPECT_FLOAT_EQ(z0-z1, v.getZ());
}


TEST_F(Point3Test, mul)
{
}


TEST_F(Point3Test, div)
{
}


TEST_F(Point3Test, memberFunctions)
{
	const Point3 p0(x0, y0, z0);
	const Point3 p1(x1, y1, z1);
	const f32 f = randf();
	Point3 p;

	// set & get
	p.set(x0, y0, z0);
	EXPECT_FLOAT_EQ(x0, p.getX());
	EXPECT_FLOAT_EQ(y0, p.getY());
	EXPECT_FLOAT_EQ(z0, p.getZ());
}


